from random import randint
from time import time

class Being:

	x = 0
	y = 0
	speed = 2
	color = "#333"
	sight_dist = 10
	
	def __init__(self, root, canvas, buildings):
		
		self.buildings = buildings
		self.last_time = time()
		#assume a collision for our first loop
		collision = True
		while(collision):
			self.x = randint(0,600)
			self.y = randint(0,400)
			collision = False
			for building in self.buildings:
				if building.hit_test(self.x,self.y):
					collision = True
		self.root = root		
		self.canvas = canvas
		self.rectangle = canvas.create_rectangle(self.x,self.y,self.x,self.y,fill=self.color,outline='')
		self.move()
	def get_x(self):
		return self.x
	def get_y(self):
		return self.y
	def set_position(self, x, y):
		move_x = x-self.x
		move_y = y-self.y
		self.x = x
		self.y = y
		self.canvas.move(self.rectangle, move_x, move_y)
	def know_beings(self, humans, zombies, player):
		self.humans = humans
		self.zombies = zombies
		self.player = player
	def set_thread(self,thread):
		self.thread = thread
	def get_thread(self):
		return self.thread